﻿<UserControl x:Class="XAMLMagicks.UserControls.ConvertersDemoControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:conv="clr-namespace:XAMLMagicks.Converters"
             xmlns:res="clr-namespace:XAMLMagicks.Properties"
             xmlns:u="clr-namespace:XAMLMagicks.UserControls"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <UserControl.Resources>
        <conv:BooleanToWaitCursorConverter x:Key="BooleanToWaitCursorConverter" />
        <conv:ByteArrayImageSourceConverter x:Key="ByteArrayImageSourceConverter" />
        <conv:CurrencyStringConverter x:Key="CurrencyStringConverter" />
        <conv:DateTimeStringConverter x:Key="DateTimeStringConverter" />
    </UserControl.Resources>
    <Grid Cursor="{Binding IsChecked, ElementName=WaitCursorCheckBox, Converter={StaticResource BooleanToWaitCursorConverter}}"
          Background="Transparent"
          VerticalAlignment="Stretch"
          >
        <StackPanel>
            <CheckBox x:Name="WaitCursorCheckBox" Content="Use Wait Cursor"
                      />
            <TextBlock Text="This image is converted from raw bytes." TextWrapping="Wrap" />
            <Image Width="300" 
                   Source="{Binding RelevantCatData, Converter={StaticResource ByteArrayImageSourceConverter}, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type u:ConvertersDemoControl}}}"
                   />
            <TextBlock Text="This text is converted to a currency string." TextWrapping="Wrap" />
            <TextBlock Text="{Binding Text, ElementName=CurrencyTextBox, Converter={StaticResource CurrencyStringConverter}}" />
            <TextBox x:Name="CurrencyTextBox" Text="4.50" />
            <TextBlock Text="This text is formatted to a date time string using a converter parameter." TextWrapping="Wrap" />
            <Calendar x:Name="DateTimeCalendar" />
            <TextBlock Text="{Binding SelectedDate, ElementName=DateTimeCalendar, 
                       Converter={StaticResource DateTimeStringConverter}, 
                       ConverterParameter='yyyyMMdd'}" 
                       />
        </StackPanel>
    </Grid>
</UserControl>
